<template>
  <div class="co-authors">
    <h4 class="title">CoAuthors</h4>
    <div class="content">
      <ul>
        <li v-for="author in authors" :key="author.authorId">
          <div class="content">
            <a class="regular-link" :href="`/#/author/${author.authorId}`" :title="author.name"><h5>{{author.name}}</h5></a>
            <span title="Co-Direction">{{author.coDirection.name}}</span>
          </div>
          <div class="line"></div>
        </li>
        <div v-if="showAll == false" class="show-more" @click="showMore">
          <span> Show All CoAuthors </span>
        </div>
        <div class="no-co-author" v-if="noCoAuthor">
          <span> No CoAuthor </span>
        </div>
      </ul>
      
    </div>
    
  </div>
</template>

<script>
export default {
  name: "CoAuthors",
  props: {
    coAuthors: Array
  },
  data() {
    return {
      showAll: false,
      noCoAuthor: false
    };
  },
  computed: {
    authors() {
      if (this.coAuthors.length < 8) {
        this.showAll = true;
      }
      if (this.coAuthors.length == 0) {
        this.noCoAuthor = true;
      }
      if(this.showAll == true) {
        return this.coAuthors;
      }
      return this.coAuthors.slice(0, 6);
    }
  },
  methods: {
    showMore() {
      this.showAll = true;
    }
  },
  components: {

  },
};
</script>

<style scoped lang="scss">
* {
  &::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  &::-webkit-scrollbar-thumb {
    border-radius: 8px;
    background-color: hsla(220, 4%, 58%, 0.3);
    transition: background-color 0.3s;

    &:hover {
      background: #bbb;
    }
  }

  &::-webkit-scrollbar-track {
    background: #ededed;
  }
}
.co-authors {
  height: 450px;
  display: flex;
  flex-direction: column;
  >h4 {
    display: flex;
    justify-content: flex-end;
    margin-right: 13px;
  }
  >.content {
    box-sizing: border-box;
    border: 1px solid #7574b83d;
    display: flex;
    flex-direction: column;
    flex: 1;
    >ul {
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      overflow: auto;
      height: 390px;
      list-style-type: none;
      padding: 10px;
      >li {
        >.content {
          padding: 5px 2px;
          >a{
            font-size: 1.3em;
            color: #490000;

            display: -webkit-box;
            overflow: hidden;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
          }

          >span{
            font-size: 0.9em;
            color: #7a7a7a;
            text-align: right;
            display: -webkit-box;
            overflow: hidden;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
          }
        }
        
      }

      >.show-more {
        display: flex;
        justify-content: center;
        margin-top: 6px;
        position: relative;
        // bottom: 80px;
        cursor: pointer;
        >span {
          color: rgb(70, 104, 20);
          padding: 10px 15px;
          border-top: 1px solid rgb(0, 201, 0);
          border-bottom: 1px solid rgb(0, 201, 0);
        }
      }

      >.no-co-author {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100%;
        font-weight: bold;
        font-size: 2em;
        color: dimgray;
        cursor: not-allowed;
        font-family: 'Nunito', sans-serif;
      }
    }
    
  }
  
}
</style>
